import config from 'config';
import httpFetch from 'share/httpFetch';

export default {
  /**
   * 查询公司配置
   * @param {string} companyOid - 公司OID
   * @returns {Function}
   */
  getConfig(companyOid) {
    // queryCode枚举值：ticketQuery, bookControl, refundChangeControl, travel
    return queryCode =>
      httpFetch.get(`${config.baseUrl}/open/airlines/api/flight/company/config`, {
        companyOid, queryCode
      });
  },
  /**
   * 更新公司配置
   * @param {string} companyOid
   * @returns {Function}
   */
  updateCompanyConfig(companyOid) {
    return data =>
      httpFetch.post(
        `${config.baseUrl}/open/airlines/api/flight/company/config`,
        {...data, companyOid}
      );
  },
  /**
   * 查询供应商列表
   * @param {string} companyOid
   * @returns {function(): *}
   */
  getVendorList(companyOid) {
    return () =>
      httpFetch.get(
        `${config.baseUrl}/open/airlines/api/flight/company/config/vendorList`,
        {companyOid}
      );
  },
  /**
   * 更新公司配置
   * @param {string} companyOid
   * @returns {function(*): *}
   */
  registerCompany(companyOid) {
    return data =>
      httpFetch.post(
        `${config.baseUrl}/open/airlines/api/flight/vendor/registerCompany`,
        {...data, companyOid}
      );
  },
  /**
   * 根据人员组id获取人员组名称
   * @param id
   */
  getGroupNameById(id) {
    return httpFetch.get(
      `${config.baseUrl}/api/user/groups/id?id=${id}`
    );
  }
};
